<?php
/*
 * 	Manhali - Free Course Management System
 *	vertical_menu.php
 *	2009-01-02 00:07
 * 	Author: El Haddioui Ismail <ismail.elhaddioui@gmail.com>
 * 	Copyright (C) 2009-2011  El Haddioui Ismail. All rights reserved
 * 	License : GNU/GPL v3

This file is part of Manhali

Manhali is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Manhali is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Manhali.  If not, see <http://www.gnu.org/licenses/>.

*/

defined("access_const") or die( 'Restricted access' );

echo "<script type=\"text/javascript\" src=\"styles/dynMenu.js\"></script>";
echo "<script type=\"text/javascript\" src=\"styles/browserdetect.js\"></script>";

// ******** titre menu vertical ********
$selmenuvertical = mysql_query("select titre_composant from `" . $tblprefix . "composants` where nom_composant = 'vertical_menu';");
if (mysql_num_rows($selmenuvertical) == 1) {
	$titre_vertical = mysql_result($selmenuvertical,0);
	if (!empty($titre_vertical)){
		$titre_vertical = html_ent($titre_vertical);
		echo "<h3><u>".$titre_vertical."</u></h3>";
	}
}
// ******** titre_qcm **************
	$selnomqcm = mysql_query("select titre_composant from `" . $tblprefix . "composants` where nom_composant = 'self_evaluation';");
	if (mysql_num_rows($selnomqcm) == 1) {
		$titre_qcm = mysql_result($selnomqcm,0);
		$titre_qcm = html_ent($titre_qcm);
		if (empty($titre_qcm))
			$titre_qcm = qcm;
	} else $titre_qcm = qcm;
	
// ******** tutoriels ********
$selecttutoriel = mysql_query("select * from `" . $tblprefix . "tutoriels` where publie_tutoriel = '2' order by ordre_tutoriel;");

if (mysql_num_rows($selecttutoriel)> 0) {

	echo "<ul id=\"menu\">\n";

	while($tutoriel = mysql_fetch_row($selecttutoriel)){

		$idtutoriel = $tutoriel[0];
		
		echo "\t<li><a href=\"?tutorial=".$idtutoriel."\">".html_ent($tutoriel[2])."</a>\n";

// ******** parties ********
		$selectpartie = mysql_query("select * from `" . $tblprefix . "parties` where id_tutoriel = $idtutoriel and publie_partie = '1' order by ordre_partie;");
	
		if (mysql_num_rows($selectpartie)> 0) {
	
			echo "\t\t<ul>\n";
	
			while($partie = mysql_fetch_row($selectpartie)){
			
				$idpartie = $partie[0];
				
				echo "\t\t\t<li><a href=\"?tutorial=".$idtutoriel."#".$idpartie."\">".html_ent($partie[2])."</a>\n";

// ******** chapitres ********
				$selectchapitre = mysql_query("select * from `" . $tblprefix . "chapitres` where id_partie = $idpartie and publie_chapitre = '1' order by ordre_chapitre;");
	
				if (mysql_num_rows($selectchapitre)> 0) {
	
					echo "\t\t\t\t<ul>\n";
	
					while($chapitre = mysql_fetch_row($selectchapitre)){
			
						$idchapitre = $chapitre[0];
						
						echo "\t\t\t\t\t<li><a href=\"?chapter=".$idchapitre."\">".html_ent($chapitre[2])."</a>\n";

// ******** blocs ********
						
						$selectbloc = mysql_query("select * from `" . $tblprefix . "blocs` where id_chapitre = $idchapitre and publie_bloc = '1' order by ordre_bloc;");
	
						if (mysql_num_rows($selectbloc)> 0) {
							
							echo "\t\t\t\t\t\t<ul>\n";
							
							while($bloc = mysql_fetch_row($selectbloc)){
			
								$idbloc = $bloc[0];
						
								echo "\t\t\t\t\t\t\t<li><a href=\"?chapter=".$idchapitre."#".$idbloc."\">".html_ent($bloc[2])."</a></li>\n";
							}
						}
						
// ******** qcm ********

						$selectqcm = mysql_query("select id_qcm from `" . $tblprefix . "qcm` where id_chapitre = $idchapitre and publie_qcm = '1';");
						if (mysql_num_rows($selectqcm)> 0){
							
							if (mysql_num_rows($selectbloc)== 0) echo "\t\t\t\t\t\t<ul>\n";
							
							echo "\t\t\t\t\t\t\t<li><a class=\"bloc\" href=\"?chapter=".$idchapitre."#qcm\">".$titre_qcm."</a></li>\n";
						
						}
						
						if (mysql_num_rows($selectbloc)> 0 || mysql_num_rows($selectqcm)> 0)
							echo "\t\t\t\t\t\t</ul>\n";
						
						echo "\t\t\t\t\t</li>\n";
					}
					echo "\t\t\t\t</ul>\n";
				}
				echo "\t\t\t</li>\n";
			}
			echo "\t\t</ul>\n";
		}
		echo "\t</li>\n";
	}
	echo "</ul>\n";
}

echo "<script type=\"text/javascript\">initMenu();</script>";

?>